/**
 *  @route
 *  @全局主要页面路径配置
 */

import React from 'react';
import {
  Image
} from 'react-native';
import { createStackNavigator, createBottomTabNavigator } from 'react-navigation';

/**
 *  @view
 *  @页面完整性导入
 */
import Login from "./pages/Login";  // 登陆
import Index from "./pages/Index";  // tab工作台
import Order from "./pages/Order";  // tab订单
import Room from "./pages/Room";    // tab房型

import OrderList from "./pages/OrderList";  // 订单管理
import OrderDetail from "./pages/OrderDetail";  // 订单管理

import SalesAmount from "./pages/SalesAmount";  // 订单管理
import SalesDetail from "./pages/SalesDetail";  // 订单管理

import ApplyMoney from "./pages/ApplyMoney"; //提现申请
import ApplyExamine from "./pages/ApplyExamine"; //提现审核
import ApplyDetail from "./pages/ApplyDetail"; //提现明细

import HotalMange from './pages/HotalMange';  //酒店管理
import RoomList from "./pages/RoomList";    // 房型管理
import AddRoom from "./pages/AddRoom"; //添加房型
import Device from "./pages/Device"; //设备信息多选

import RoomProtect from '../src/pages/RoomProtect'; //房间维护

/**
 *  @icon
 *  @tabBar需求icon导入
 */
const indexImage = require("./assets/images/icon/index.png");
const indexImageSel = require("./assets/images/icon/index2.png");
const orderImage = require("./assets/images/icon/order.png");
const orderImageSel = require("./assets/images/icon/order2.png");
const roomImage = require("./assets/images/icon/room.png");
const roomImageSel = require("./assets/images/icon/room2.png");

const tabBar = createBottomTabNavigator({
  Index: {
    screen: Index,
    navigationOptions: {
      tabBarLabel: '工作台'
    }
  },
  Order: {
    screen: Order,
    navigationOptions: {
      tabBarLabel: '订单'
    }
  },
  Room: {
    screen: Room,
    navigationOptions: {
      tabBarLabel: '房型'
    }
  }
}, {
    tabBarPosition: 'bottom',
    animationEnabled: true,
    swipeEnabled: false,
    lazy: true,
    animationEnabled: true,
    navigationOptions: ({ navigation }) => ({
      tabBarIcon: ({ focused }) => {
        const { routeName } = navigation.state;
        let iconName;
        if (routeName === 'Index') {
          iconName = !focused ? indexImage : indexImageSel;
        } else if (routeName === 'Order') {
          iconName = !focused ? orderImage : orderImageSel;
        } else if (routeName === 'Room') {
          iconName = !focused ? roomImage : roomImageSel;
        }
        return <Image style={{ width: 22, height: 22 }} source={iconName} />;
      },
    }),
    tabBarOptions: {
      activeTintColor: '#3496f0',
      inactiveTintColor: 'gray',
    },
  });

export default createStackNavigator({

  tabBar: {
    screen: tabBar,
    navigationOptions: {
      headerTitle: '互联家',
      headerLeft: null
    }
  },
  OrderList: {
    screen: OrderList
  },
  OrderDetail: {
    screen: OrderDetail
  },
  SalesAmount: {
    screen: SalesAmount
  },
  SalesDetail: {
    screen: SalesDetail
  },
  RoomList: {
    screen: RoomList
  },
  Login: {
    screen: Login
  },
  ApplyMoney: {
    screen: ApplyMoney
  },
  ApplyExamine: {
    screen: ApplyExamine
  },
  ApplyDetail: {
    screen: ApplyDetail
  },
  HotalMange: {
    screen: HotalMange
  },
  AddRoom: {
    screen: AddRoom
  },
  Device: {
    screen: Device
  },
  RoomProtect: {
    screen: RoomProtect
  }
}, {
    initialRouteName: 'Login',
    navigationOptions: ({ navigation }) => ({
      title: navigation.state.routeName,
      headerStyle: {
        backgroundColor: '#ffffff',

      },
      headerTintColor: '#000000',
      headerTitleStyle: {
        flex: 1,
        textAlign: 'center',
      }
    }),
  });

Array.prototype.remove = function (val) {
  var index = this.indexOf(val);
  if (index > -1) {
    this.splice(index, 1);
  }
}; 